/**
 * GTHttpRequest.h
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License 
 * at http://www.mozilla.org/MPL/
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied. See the License for the specific language governing rights and limitations 
 * under the License.
 *
 * The Original Code is gcast-toolbox4iphone.
 *
 * The Initial Developers of the Original Code is Giannandrea Castaldi.
 */
#import <Foundation/Foundation.h>

typedef enum {
  GTHttpStatusCodeError = 0,
  GTHttpStatusCodeOk = 200,
  // Redirection 3xx
  GTHttpStatusCodeMoved = 301,
  GTHttpStatusCodeFound = 302,
  GTHttpStatusCodeMethod = 303,
  GTHttpStatusNotModified = 304,
  // Error 4xx, 5xx
  GTHttpStatusCodeBadRequest = 400,
  GTHttpStatusCodeUnauthorized = 401,
  GTHttpStatusCodePaymentRequired = 402,
  GTHttpStatusCodeForbidden = 403,
  GTHttpStatusCodeNotFound = 404
} GTHttpStatusCode;

/**
 * Next steps that may be followed:
 * - Split GTHttpRequest in two classes:
 *    - GTHttpRequestBuilder: its work is to build NSURLRequest
 *    - GTHttpRequestExecuter: its work is to execute NSURLRequest and offer the result data
 */
@interface GTHttpRequest : NSObject {
	NSURL *url;
  NSMutableDictionary *parameters;
  NSString *httpResult;
  NSDictionary *allHeaderFields;
	NSString *errorDescription;
  BOOL logEnabled;
}
@property(nonatomic,retain,readonly) NSString *httpResult;
@property(nonatomic,retain,readonly) NSDictionary *allHeaderFields;
@property(nonatomic,retain,readonly) NSString *errorDescription;
@property(nonatomic,assign,readwrite) BOOL logEnabled;

+ (id)requestWithURL:(NSURL*)anUrl;
+ (id)requestWithUrl:(NSString*)anUrl;
- (id)initWithURL:(NSURL*)anUrl;
- (id)initWithUrl:(NSString*)newUrl;
- (GTHttpStatusCode)sendHttpGet;
- (GTHttpStatusCode)sendHttpPost;
- (void)setParameter:(NSString*)aName withValue:(NSString*)aValue;
- (NSString*)parameterValueForName:(NSString*)aName;

@end
